﻿@{
    ViewBag.Title = "Quản lý nhận xét trường học";
    Layout = "~/Views/Shared/BE/_Admin_Layout.cshtml";
}

<article class="module width_3_quarter">
<div id="SchoolCommentTable"></div>
</article>

<script type="text/javascript">

    $(document).ready(function () {

        //Prepare jtable plugin
        $('#SchoolCommentTable').jtable({
            //...
            selecting: true, //Enable selecting
            multiselect: true, //Allow multiple selecting
            selectingCheckboxes: true, //Show checkboxes on first column
            openChildAsAccordion: true,
            paging: true,
            pageSize: 10,
            defaultSorting: 'SchoolName DESC',
            sorting: true,

            title: 'Danh sách các bình luận',
            actions: {
                listAction: '@Url.Action("ListComment","SchoolManagement")',
                deleteAction: '@Url.Action("DeleteComment","SchoolManagement")',
                updateAction: '@Url.Action("UpdateComment","SchoolManagement")'
                //createAction: '/SchoolManagement/CreateComment'
            },
            fields: {
                CommentID: {
                    key: true,
                    create: false,
                    edit: false,
                    list: false
                },
                SchoolName: {
                    title: 'Tên trường',
                    width: '15%',
                    edit: false
                },
                CommentContent: {
                    title: 'Nội dung',
                    type: 'textarea',
                    inputClass: 'validate[required,maxSize[1000]]'
                },
                UserName: {
                    title: 'Người gửi',
                    edit: false
                },
                CreatedTime: {
                    title: 'Ngày gửi nhận xét',
                    type: 'date',
                    displayFormat: 'dd-mm-yy',
                    edit: false
                }
            },
            //Initialize validation logic when a form is created
            formCreated: function (event, data) {
                $(data.form[0]).submit(function () {
                    return false;
                });
                data.form.validationEngine();
            },
            //Validate form when it is being submitted
            formSubmitting: function (event, data) {
                return data.form.validationEngine('validate');
            },
            //Dispose validation logic when form is closed
            formClosed: function (event, data) {
                data.form.validationEngine('hide');
                data.form.validationEngine('detach');
            }
        });
        //Re-load records when user click 'load records' button.
        $('#LoadRecordsButton').click(function (e) {
            e.preventDefault();
            $('#SchoolCommentTable').jtable('load', {
                keywords: $('#name').val(),
            });
        });
        //Load person list from server
        $('#SchoolCommentTable').jtable('load');
        
        //Delete selected students
        $('#DeleteAllButton').button().click(function () {
            var $selectedRows = $('#SchoolCommentTable').jtable('selectedRows');
            $('#SchoolCommentTable').jtable('deleteRows', $selectedRows);
        });
    });

</script>

